package leetcode.hot100;

import java.util.HashSet;
import java.util.Set;

public class number204 {
    public static void main(String[] args) {
        System.out.println(countPrimes(3));
    }
    public static int countPrimes(int n) {
        if(n<=2){
            return n;
        }
        Set<Integer> set = new HashSet<>();
        for(int i=2;i<=n/2;i++){
            for(int j=i;j<=n/2;j++){
                if(i*j>n){
                    break;
                }
                set.add(i*j);
            }
        }
        int count=0;
        for(int i=2;i<n;i++){
            if(!set.contains(i)){
                count++;
                System.out.print(i+" ");
            }
        }
        System.out.println();
        return count;
    }
}
